//
//  ConditionNumberView.swift
//  MakeMoney
//
//  Created by Fan ZhiQiang on 2024/12/26.
//

import SwiftUI

struct ConditionNumberView: View {
    let number: Int
    let conditionArea: ConditionArea
    //var closure: (Int) -> Void
    @Binding var selectNumber: Int
    
    private var range: Range<Int> {
        switch conditionArea {
        case .front:
            return 0..<36
        case .hind:
            return 0..<13
        case .ball:
            return 0..<4
        }
    }
    
    private var title: String {
        switch conditionArea {
        case .front:
            return "请选择前区号码\(number)"
        case .hind:
            return "请选择后区号码\(number)"
        case .ball:
            return "请选择摇奖球"
        }
    }
    
    var body: some View {
        Picker("请选择\(number)", selection: $selectNumber) {
            ForEach(range) { index in
                Text(index == 0 ? "不选择" : "\(index)")
            }
        }
//        .onChange(of: selectNumber) {
//            closure(selectNumber)
//        }
    }
    
    enum ConditionArea: String {
        case front, hind, ball
    }
}

#Preview {
    ConditionNumberView(number: 1, conditionArea: .front, selectNumber: .constant(1))
}
